package com.whmskj.xjlhsc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.whmskj.xjlhsc.mapper.DbStatisticsMapper;
import com.whmskj.xjlhsc.entity.DbStatistics;
import com.whmskj.xjlhsc.mapper.Gy01VarietiesMaintenanceTableMapper;
import com.whmskj.xjlhsc.service.DbStatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import lombok.extern.slf4j.Slf4j;
import java.util.List;

/**
 * @author lk
 * @since 2025-07-11 11:26:13
 */
@Service
@Slf4j
public class DbStatisticsServiceImpl extends ServiceImpl<DbStatisticsMapper, DbStatistics> implements DbStatisticsService {

    @Autowired
    private DbStatisticsMapper dbStatisticsMapper;

    @Autowired
    private Gy01VarietiesMaintenanceTableMapper gy01VarietiesMaintenanceTableMapper;

    @Override
    public Page<DbStatistics> findPage(DbStatistics params) {
        Page<DbStatistics> page = new Page<>(1, 10);//TODO 自行处理
        LambdaQueryWrapper<DbStatistics> query = Wrappers.lambdaQuery(DbStatistics.class);
        return dbStatisticsMapper.selectPage(page, query);
    }

    @Override
    public List<DbStatistics> findList(DbStatistics params){
        LambdaQueryWrapper<DbStatistics> query = Wrappers.lambdaQuery(DbStatistics.class);
        return dbStatisticsMapper.selectList(query);
    }

    @Override
    public DbStatistics findById(Long id) {
        return dbStatisticsMapper.selectById(id);
    }

    @Override
    public boolean insert(DbStatistics dbStatistics) {
        return save(dbStatistics);
    }

    @Override
    public boolean update(DbStatistics dbStatistics) {
        return updateById(dbStatistics);
    }

    @Override
    public int delete(Long id) {
        return dbStatisticsMapper.deleteById(id);
    }

    @Override
    public List<String> getAllClassNames() {
        return dbStatisticsMapper.selectAllClassNames();
    }

    @Override
    public List<String> getAllNameOfSpecies() {
        return gy01VarietiesMaintenanceTableMapper.selectAllNameOfSpecies();
    }

}